<template>
	<view>
		<simple-toolbar :title="$t('wallet.wallet.wallet')">
			<view class="update">
				<view class="button" @click="edit(1)">
					<image src="../../../static/create.png"></image>
					<text>{{ $t('wallet.wallet.newWallet') }}</text>
				</view>
			</view>
		</simple-toolbar>
		
		<view class="pad-base table">
			<el-table :data="formData" style="width: 100%">
				<el-table-column align="center" prop="wallet" :label="$t('wallet.wallet.address')"></el-table-column>
				<el-table-column align="center" prop="coin_name" :label="$t('wallet.wallet.coin')"></el-table-column>
				<el-table-column align="center" :label="$t('wallet.wallet.operation')" width="80">
					<template slot-scope="scope">
						<el-button @click.native.prevent="edit(2,scope.$index)" type="text" size="small">
							{{ $t('wallet.wallet.modify') }}
						</el-button>
					</template>
				</el-table-column>
			</el-table>
		</view>
	</view>
</template>

<script>
	import {
		wallet
	} from "../../../js_sdk/uni-admin/wallet.js"

	export default {
		data() {
			return {
				formData: []
			}
		},
		onShow() {
			this.loadData()
		},
		methods: {
			edit(operation, idx) {
				uni.navigateTo({
					// operation: 1新建 2修改
					url: `./editWallet?operation=${operation}&data=${encodeURIComponent(JSON.stringify(this.formData[idx]))}`
				})
			},
			async loadData() {
				let res = await wallet()
				this.formData = res.data
			}
		}
	}
</script>

<style lang="scss" scoped></style>
